Skip to content

fix(id): #5644 bound retained one-time state in HostedBindingService - #6319

Merged
dezren39 merged 2 commits into
mainfrom
queue/10601-5644-bound-one-time-state
Nov 5, 2026
Merged

dezren39 merged 2 commits into
mainfrom
queue/10601-5644-bound-one-time-state

Conversation

@dezren39

@dezren39 dezren39 commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Implements issue #5644 (task 10601): bounded retention for the one-time ceremony maps in pkgs/id/src/hosted_binding.rs.

  • Consumed-challenge markers now store the consumed challenge's original expires_at (HashMap<String, u64> instead of a lifetime HashSet). Replay is still rejected through the whole validity window; past it the marker is pruned on access (replay_blocked) or by sweep, and a late presentation reports UnknownChallenge instead of ChallengeReplay — the post-expiry error-semantics change the issue's audit note (b) prescribed.
  • Bounded sweep (prune_expired_one_time_state) removes expired unconsumed challenges, expired unexchanged pairing codes, and expired consumed markers. It runs from the rate-limited minting paths: request_challenge, and create_pairing_code (before the collision loop, so an expired code stops reserving its six-digit value, per audit note (a)).
  • Header lifecycle dispositions (a)/(b) and the request_challenge/create_pairing_code table rows updated to match.
  • New tests: marker blocks replay until the original expiry boundary then reports UnknownChallenge; expired unconsumed challenge is swept by the next request; expired pairing code is swept and stops reserving its value.

Existing expiry semantics elsewhere are unchanged (submit_proof/verify_challenge_proof expiry stays state-free per §3.4/#4868; exchange of a not-yet-swept expired code still returns ChallengeExpired).

Closes #5644.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner November 5, 2026 17:03
@coderabbitai

coderabbitai Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

Clippy (1.99.1)

Clippy execution timed out

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-05T17:09:38.351024Z f534266 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2fa9106cce

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread pkgs/id/src/hosted_binding.rs Outdated
iroh_id: &IrohId,
) -> Result<Challenge, CeremonyError> {
let now = self.now();
self.prune_expired_one_time_state(now);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Apply the issuance limit before sweeping global state

When the service holds many live challenges or pairing codes, every request_challenge call now scans all three one-time maps before checking the caller's issuance limit. A caller that has already exhausted its 30 challenges per hour can therefore trigger unlimited full-map sweeps through requests that return RateLimited, introducing work proportional to global state on the rejection path. Move the sweep after the rate-limit check, as create_pairing_code already does, so rejected requests cannot repeatedly trigger this cleanup.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit f534266: the sweep in request_challenge now runs after the rate-limit check (and after the issuance is logged), matching create_pairing_code — a rate-limited caller gets RateLimited without triggering any map cleanup.

@codex review

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: f534266ad8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@dezren39
dezren39 merged commit 08c51c6 into main Nov 5, 2026
1 check failed
@dezren39
dezren39 deleted the queue/10601-5644-bound-one-time-state branch November 5, 2026 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bound retained one-time state in HostedBindingService

1 participant